//
//  DataManager.h
//  Seizure

// Singleton façade to provide controllers access to all information 
//
//  Copyright (c) 2012 Rowan University. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "LocalData.h"
#import "DBCommunicator.h"
#import "NetworkData.h"

@class Account;

@interface DataManager : NSObject

@property (strong) Account *user;
@property (strong) LocalData *local;
@property (strong) DBCommunicator *dbcenter;

+ (DataManager *)sharedInstance;


// ----- Fetching information
- (LinkedAccount *) fetchPatient;
- (NSArray*) fetchCaretakers:(id <NetworkData>)delegate requestType:(short)rtype;
- (Account*) getStoredAccount;


// ----- Creating a new account
- (void) createAccountWithEmail:(NSString*)email withName:(NSString*)name withPassword:(NSString*)password                                                              isPatient:(Boolean)isPatient;
- (void) uploadUserWithPassword:(NSString*)password delegate:(id<NetworkData>)delegate requestType:(short)rtype;
// ----- Creating (fake/Seizure Detection Only) account
- (void) createFakeAccount;
- (BOOL) usingFakeAccount;

// ----- logging in
- (void) loginUser:(NSString*)email password:(NSString*)password delegate:(id<NetworkData>)delegate requestType:                (short)rtype;
- (void) storeAccount:(Account*)account;


// ----- Patient - Caretaker relationships
- (NSString*)    createPatientCaretakerConnection:(Account *)requestingAccount emailOfRequested:(NSString *)email;
- (BOOL)    removePatientCaretakerConnection:(Account *)initiatingAccount emailToDisconnect:(NSString *)email;
- (BOOL)    confirmPatientCaretakerConnection:(NSString *)caretakersEmail;


// ----- Sensitivity Related
- (BOOL)    updatePatientSensitivity:(NSString *)patientEmail sensitivity:(NSNumber *)sensitivity;
- (NSNumber*)getPatientSensitivity:(NSString *)patientEmail;

// ----- Misc
- (void) userLoggedOut;
- (void) uploadAPNSKey:(NSString*)key;
- (void)pushAlertCaretakersWithLocation:(CLLocation*)location;
- (BOOL)resetPassword:(NSString*)email;


// ----- Log Related Methods  
- (void)addPatientEventLog:(EventLog *)eventLog;
- (void)addPatientEventLogWithoutLocal:(EventLog *)eventLog;
- (NSArray*)getPatientEventLogs:(id<NetworkData>)target requestType:(int)rtype;
- (void)archiveLocalLogs:(NSArray *)eventLogs;
- (NSArray*)getLocalLogs;


@end
